package com.ruoyi.web.controller.app;

import java.util.Date;
import java.util.List;

import com.ruoyi.common.annotation.Anonymous;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.AppUserApply;
import com.ruoyi.system.service.IAppUserApplyService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 理赔申请Controller
 *
 * @author ruoyi
 * @date 2025-06-28
 */
@Api(value = "理赔申请接口", description = "理赔申请接口")

@RestController
@RequestMapping("/app/appUserApply")
public class ApplyCenterController extends BaseController {
    @Autowired
    private IAppUserApplyService appUserApplyService;

    /**
     * 查询理赔申请列表
     */
    @ApiOperation("查询理赔申请列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id", dataType = "Long"),
            @ApiImplicitParam(name = "userId", value = "所属用户", dataType = "Long"),
            @ApiImplicitParam(name = "realName", value = "姓名", dataType = "String"),
            @ApiImplicitParam(name = "phone", value = "手机号", dataType = "String"),

    })

    @GetMapping("/list")
    public TableDataInfo list(AppUserApply appUserApply) {
        startPage();
        List<AppUserApply> list = appUserApplyService.selectAppUserApplyList(appUserApply);
        return getDataTable(list);
    }

    /**
     * 获取理赔申请详细信息
     */
    @ApiOperation("获取理赔申请详细信息")
    @ApiImplicitParam(name = "id", value = "理赔申请ID", required = true, dataType = "Long", paramType = "query")
    @GetMapping(value = "/detail")
    public AjaxResult getInfo(@RequestParam("id") Long id) {
        return success(appUserApplyService.selectAppUserApplyById(id));
    }

    /**
     * 新增理赔申请
     */
    @ApiOperation("新增理赔申请")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "所属用户", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "realName", value = "姓名", required = true, dataType = "String"),
            @ApiImplicitParam(name = "phone", value = "手机号", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "certificateType", value = "证件类型", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "certificateCode", value = "证件号码", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "validityTime", value = "证件有效期", required = true, dataType = "Date" , dataTypeClass = Date.class, example = "yyyy-MM-dd"),
            @ApiImplicitParam(name = "sex", value = "性别 1男 2女", required = true, dataType = "Integer" ),
            @ApiImplicitParam(name = "birthday", value = "出生日期", required = true, dataType = "Date" , dataTypeClass = Date.class, example = "yyyy-MM-dd"),
            @ApiImplicitParam(name = "occurTime", value = "出险日期", required = true, dataType = "Date" , dataTypeClass = Date.class, example = "yyyy-MM-dd"),
            @ApiImplicitParam(name = "occurDes", value = "出险描述", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "lingkuanRealName", value = "领款姓名", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "lingkuanBlankName", value = "领款银行名称", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "lingkuanBlanCode", value = "领款银行卡号", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "relationshipImages", value = "关系证明图", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "blankImages", value = "银行卡图", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "yiliaoImages", value = "医疗费用图", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "bingImages", value = "病历图", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "deleted", value = "是否删除", required = true, dataType = "Integer" ),
            @ApiImplicitParam(name = "applyStatus", value = "申请状态", required = true, dataType = "Integer" )
    })
    @PostMapping("/add")
    public AjaxResult add(@RequestBody AppUserApply appUserApply) {
        return toAjax(appUserApplyService.insertAppUserApply(appUserApply));
    }

    @PostMapping("/submit")
    public AjaxResult submit(@RequestBody AppUserApply appUserApply) {
        appUserApplyService.saveOrUpdate(appUserApply);
        return toAjax(appUserApplyService.saveOrUpdate(appUserApply));
    }


    /**
     * 修改理赔申请
     */
    @ApiOperation("修改理赔申请")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long" ),
            @ApiImplicitParam(name = "userId", value = "所属用户", required = true, dataType = "Long" ),
            @ApiImplicitParam(name = "realName", value = "姓名", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "phone", value = "手机号", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "certificateType", value = "证件类型", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "certificateCode", value = "证件号码", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "validityTime", value = "证件有效期", required = true, dataType = "Date" , dataTypeClass = Date.class, example = "yyyy-MM-dd"),
            @ApiImplicitParam(name = "sex", value = "性别 1男 2女", required = true, dataType = "Integer" ),
            @ApiImplicitParam(name = "birthday", value = "出生日期", required = true, dataType = "Date" , dataTypeClass = Date.class, example = "yyyy-MM-dd"),
            @ApiImplicitParam(name = "occurTime", value = "出险日期", required = true, dataType = "Date" , dataTypeClass = Date.class, example = "yyyy-MM-dd"),
            @ApiImplicitParam(name = "occurDes", value = "出险描述", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "lingkuanRealName", value = "领款姓名", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "lingkuanBlankName", value = "领款银行名称", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "lingkuanBlanCode", value = "领款银行卡号", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "relationshipImages", value = "关系证明图", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "blankImages", value = "银行卡图", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "yiliaoImages", value = "医疗费用图", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "bingImages", value = "病历图", required = true, dataType = "String" ),
            @ApiImplicitParam(name = "deleted", value = "是否删除", required = true, dataType = "Integer" ),
            @ApiImplicitParam(name = "applyStatus", value = "申请状态", required = true, dataType = "Integer" )
    })
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody AppUserApply appUserApply) {
        return toAjax(appUserApplyService.updateAppUserApply(appUserApply));
    }
}
